﻿using System;
using System.Linq;
using Wicresoft.EKA.MVCExtensions;
using Wicresoft.EKA.ITSM.Business;
using System.Collections.Generic;

namespace Wicresoft.EKA.ITSM.BusinessImpl
{
    public class User : Base, IUser
    {
        protected override void Dispose(bool disposing)
        {
        }

        public UserModel GetUserByLoginID(string ID)
        {
            var proxy = this.GetARProxy<UserModel>();
            return proxy.GetListEntry("'Login Name'=\"" + ID + "\"", new System.Collections.Generic.List<uint>()
                {
                    UserModel.LoginName_ID,
                    UserModel.RequestID_ID,
                    UserModel.Password_ID
                }).FirstOrDefault();
        }
        public System.Collections.Generic.IEnumerable<UserModel> GerUsers()
        {
            return this.GetARProxy<UserModel>().GetListEntry("1=1", new System.Collections.Generic.List<uint>()
            {
                UserModel.FullName_ID,
                UserModel.LoginName_ID
            });
        }

        public List<SMGXJGroupAssoModel> GetGroupAsso(string LoginName,string isArtechGroup) {
            var list = this.GetARProxy<SMGXJGroupAssoModel>().GetListEntry("'LoginID' = \"" + LoginName + "\" AND 'IsArtechGroup' =\"" + isArtechGroup + "\" AND 'Disabled' = \"No\"", new System.Collections.Generic.List<uint>()
            {
                SMGXJGroupAssoModel.Disabled_ID,
                SMGXJGroupAssoModel.FullName_ID,
                SMGXJGroupAssoModel.GroupID_ID,
                SMGXJGroupAssoModel.IsArtechGroup_ID,
                SMGXJGroupAssoModel.LoginID_ID,
                SMGXJGroupAssoModel.GroupName_ID
            }).ToList();
            return list;
        }

    }
}
